package com.carl.leetcode.pointer;

/**
 * Created by carlXie on 2016/1/12.
 * email: kkrimen@gmail.com
 */
public class ContainerWithMostWater {
    public static void main(String[] args) {
        int[] height = new int[]{1, 1};
        System.out.println(maxArea(height));
    }

    public static int maxArea(int[] height) {
        int area = 0;
        int i = 0;
        int j = height.length - 1;
        while(i < j) {
            area = Math.max(area, (j - i) * Math.min(height[i], height[j]));
            if(height[i] < height[j])
                i ++;
            else j --;
        }

        return area;
    }
}
